package com.ruoyi.business.enums;

import java.util.Arrays;
import java.util.Optional;

public enum AccountBusiTypeEnum {
    RECHARGE(1,"充值") ,
    MESSAGE(2,"购买信息") ,
    REFUND(3,"退款") ;
    private Integer code ;
    private String desc ;

    AccountBusiTypeEnum(int code, String desc){
        this.code = code ;
        this.desc = desc ;
    }

    public static boolean checkExist(int code){

        Optional<AccountBusiTypeEnum> dealOp = Arrays.stream(AccountBusiTypeEnum.values()).filter(deal -> deal.code == code).findFirst() ;
        return dealOp.isPresent() ;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(Integer code){
        Optional<AccountBusiTypeEnum> dealOp = Arrays.stream(AccountBusiTypeEnum.values()).filter(deal -> deal.code == code.intValue()).findFirst() ;
        return dealOp.get().desc ;
    }
}
